package ${package.Controller};

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.pine.common.beans.ResultVo;
import ${package.QueryRequest}.${QueryRequestName};
import ${package.QueryResponse}.${QueryResponseName};
import com.pine.common.beans.request.IdRequest;
import com.pine.common.beans.request.PageRequest;
import com.pine.common.beans.response.PageResponse;
import com.pine.common.systemlog.annotation.SysLog;
import ${package.SaveOrUpdateRequest}.${SaveOrUpdateRequestName};
import ${package.Service}.${ServiceName};
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Tag(name = "${table.comment!}前端控制器")
@RestController
@RequestMapping("/${entityLowerCaseFirstOne}")
public class ${ControllerName} {

    @Resource
    private ${ServiceName} ${entityLowerCaseFirstOne}Service;

    /**
     * 分页查询
     *
     * @param request 请求
     * @return 分页响应
     */
    @SaCheckLogin
    @Operation(summary = "分页查询")
    @PostMapping("/pages")
    @SysLog("分页查询")
    public ResultVo<${pageResponseName}<${QueryResponseName}>> listPages(@RequestBody @Valid ${pageRequestName}<${QueryRequestName}> request) {
        request.defaultPage();
        return ResultVo.success(${entityLowerCaseFirstOne}Service.listPages(request));
    }


    /**
     * 查询信息（不分页）
     *
     * @param request 请求
     * @return PageResponse 响应
     */
    @SaCheckLogin
    @Operation(summary = "查询信息（不分页）")
    @PostMapping("/list")
    @SysLog("查询信息（不分页）")
    public ResultVo<${listString}<${QueryResponseName}>> list(@RequestBody @Valid ${QueryRequestName} request) {
        return ResultVo.success(${entityLowerCaseFirstOne}Service.list(request));
    }


    /**
     * 查询详细信息
     *
     * @param request 请求
     * @return 响应
     */
    @SaCheckLogin
    @PostMapping(value = "/detail")
    @Operation(summary = "查询详细信息")
    @SysLog("查询详细信息")
    public ResultVo<${QueryResponseName}> getDetail(@RequestBody @Valid IdRequest<${primaryKeyType}> request) {
        return ResultVo.success(${entityLowerCaseFirstOne}Service.getOneByUniqueKey(request.getId(), "id"));
    }

}
